package com.mxnavi5.example.DataStream;


import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

public class SourceTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        //2.source
        // * 1.env.fromElements(可变参数);
        DataStream<String> ds1 = env.fromElements("meixing", "navi", "flink");
        // * 2.env.fromColletion(各种集合);
        DataStream<String> ds2 = env.fromCollection(Arrays.asList("hadoop", "spark", "flink"));
        // * 3.env.generateSequence(开始,结束);
        DataStream<Long> ds3 = env.generateSequence(1, 10);

        DataStreamSource<String> ds4 =
                env.readTextFile("E:\\workspace\\flink-example\\src\\main\\resources\\hello.txt");

        ds1.print("Collection:ds1");
        ds2.print("Collection:ds2");
        ds3.print("Collection:ds3");


        ds4.print("File:ds4");


        env.execute();


    }
}
